require "rexml/document"
include REXML

class ErrorResponse
  
  attr_accessor :error_code, :error_description
  
  def initialize()
  
  end

  def self.element_value(node, expression)
    
    elements = node.elements[expression]
    
    if (elements != nil) 
      return elements[0].to_s()
    else
      return nil
    end
    
  end
  
  def self.fromXml(doc) 
   
    r = ErrorResponse.new()
    r.error_code = element_value(doc, "error-response/error-code")
    r.error_description = element_value(doc, "error-response/error-description")
  
    return r
    
  end
  
end